package xiaojian.toolkit.netty.transport;

import io.netty.channel.ChannelHandlerContext;
import io.netty.util.AttributeKey;
import xiaojian.toolkit.netty.transport.endpoint.Endpoint;

public class TransportUtils extends xiaojian.toolkit.base.TransportUtils {
	private static final AttributeKey<Endpoint> TRANSPORT_ENDPOINT = AttributeKey
			.valueOf("TRANSPORT_ENDPOINT");

	public static void attachEndpointToSession(ChannelHandlerContext ctx,
			Endpoint endpoint) {
		ctx.channel().attr(TRANSPORT_ENDPOINT).set(endpoint);
	}

	public static Endpoint getEndpointOfSession(ChannelHandlerContext ctx) {
		return ctx.channel().attr(TRANSPORT_ENDPOINT).get();
	}

}
